

namespace Stee.CAP8.MessageBus.Interfaces.Interfaces
{
    using System;
    using System.Collections.Generic;
    using Stee.CAP8.MessageBus.Interfaces.Delegates;

    /// <summary>
    /// Dead-letter queue interface
    /// </summary>
    public interface IDeadLetterQueue : IDisposable
    {
        #region Properties

        /// <summary>
        /// Gets the flag indicating that admin client is initialized and ready for configuration
        /// </summary>
        bool IsInitialized { get; }

        /// <summary>
        /// Gets the flag indicating disposed state
        /// </summary>
        bool IsDisposed { get; }

        #endregion Properties


        /// <summary>
        /// Initialize the dead-letter queue monitor tool
        /// </summary>
        /// <param name="brokerConfigurationJSON">JSON configuration file path</param>
        /// <param name="topicRetention">Operational topic retention time before messages deemed expired</param>
        /// <param name="adminErrorHandler">Admin client error handler</param>
        /// <param name="publishErrorHandler">Publisher error handler</param>
        /// <param name="subscribeErrorHandler">Subscriber error handler</param>
        /// <returns>Return TRUE if initialized else FALSE</returns>
        bool Initialize(string brokerConfigurationJSON, TimeSpan topicRetention,
            HandleBrokerError adminErrorHandler, HandleBrokerError publishErrorHandler, HandleBrokerError subscribeErrorHandler);

        /// <summary>
        /// Check for & process all expired messages in all message broker topics
        /// </summary>
        /// <param name="topicSubscribeGroupMapping">Configured topic to subscriber group mapping</param>
        /// <returns>Return TRUE if processed successfully regardless of new expired message(s) found else FALSE</returns>
        bool CheckForExpiredMessages(IDictionary<string, HashSet<string>> topicSubscribeGroupMapping);

        /// <summary>
        /// Cancel check for new expired messages
        /// </summary>
        /// <returns>Return TRUE if cancelled successfully else FALSE</returns>
        bool CancelCheck();
    }
}
